<?php

class ElementosDeArrayNoRepetidosValidator extends sfValidatorBase
{
	
	protected function configure($options = array(), $messages = array()) {
		$this->addOption('campos');
	}	
	
	protected function doClean($value)
	{
		$bag = array();
		$elementos[] = array();
		foreach ($this->getOption('campos') as $campo){
			$elementos[] = $value[$campo];
		}
		foreach($elementos as $valor) {
			if (!$this->isEmpty($valor)) {
				if(isset($bag[$valor]))  {
					throw new sfValidatorError($this, 'invalid', array('value' => $value));
				}
				$bag[$valor] = true; 
			}
		}
		return $value;
	}

}
